//获取应用实例
import regeneratorRuntime from '../../utils/regenerator-runtime/runtime'
const utils = require('../../utils/util.js');
const app = getApp()

Page({
  data: {
    url:"sendMessage",
    formIds:[],
    enable:false,
    nickname:""
  },
  onLoad:function(){
    if(!app.globalData.userInfo){
      wx.redirectTo({
        url: '../start/index'
      })
    }
  },
  updateText:function(e){
    var value=e.target.value;
    this.setData({
      nickname:value,
      enable:!!values
    })
  },
  sendCeshi:async function(e){
    wx.showLoading({
      title: '提交中...'
    })
    const token=await app.getToken();
    app.request("/api/message/send",{keyword1:"测试消息推送",keyword2:"办卡成功",keyword3:"2019年1月",token:token},function(res){
      if(res.data.state){
        wx.hideLoading();
        wx.showToast({
          title: '发送成功',
          icon: "none",
          duration: 2000
        })
      }
      else{
        wx.hideLoading();
        wx.showToast({
          title: '发送失败,请重试',
          icon: "none",
          duration: 2000
        })
      }
    },function(){
      wx.hideLoading();
        wx.showToast({
          title: '发送失败,请重试',
          icon: "none",
          duration: 2000
        })
    })
  },
  jumpUrl:function(){
    wx.redirectTo({
      url: '../index2/index'
    })
  }
})
